<template>
    <div>
      <router-link to="/userrec"><h1>我的所有历史训练记录</h1></router-link>
      <a href="javascript:;" @click="cust"><h1>查看教练的所有客户记录</h1></a>
      <table border="1">
        <tr>
          <th>用户名</th>
          <th>开始时间</th>
          <th>结束时间</th>
          <th>费用</th>
          <th>选择的教练</th>
        </tr>
        <tr v-for="i in show_member" :key="i.id">
          <th>{{i.member.name}}</th>
          <th>{{i.start_time}}</th>
          <th>{{i.end_time}}</th>
          <th>{{i.total}}</th>
          <th>{{i.coach.name}}</th>

        </tr>
      </table>
    </div>
</template>

<script>
    export default {
        name: "Member",
      data(){
          return{
            show_member:[],
            id:this.$route.query.id,
            uid:sessionStorage.getItem("id"),

          }
      },
      methods:{
          cust(){
            this.$router.push({
              "name":"CoachRecord",
              query:{
                "id":this.id
              }
            })
          }
      },
      created() {
          console.log(this.id)
          this.axios({
            "url":"cart/",
            "method":"GET",
            "params":{
              uid:this.uid,
              coach:this.id
            }
          })
        .then(resp=>{
          console.log(resp.data)
          this.show_member = resp.data
        }).catch(err=>{
          console.log(err)
          })
      }
    }
</script>

<style scoped>

</style>
